<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arrObj = [
        { id: 1, name: 'wmj' },
        { id: 3, name: 'qwe' },
        { id: 4, name: 'asd' },
        { id: 2, name: 'gfg' }
      ]
      console.log(arrObj.sort((a, b) => a.id - b.id))

      const objectArr = [
        { first_name: 'Lazslo', last_name: 'Jamf' },
        { first_name: 'Pig', last_name: 'Bodine' },
        { first_name: 'Pirate', last_name: 'Prentice' }
      ]
      objectArr.sort((a, b) => a.last_name.localeCompare(b.last_name))
      console.log(objectArr)
    </script>
  </body>
</html>
